const initialState = {
  msg: "~",
  count: 1,
};

export default function appReducer(state = initialState, action: any) {
  switch (action.type) {
    case "INCREMENT":
      return {
        ...state,
        count: state.count + 1,
      };
    case "DECREMENT":
      return {
        ...state,
        count: state.count - 1,
      };

    case "CHANGEMSG":
      return {
        ...state,
        msg: action.payload || state.msg + "~",
      };

    default:
      return state;
  }
}
